<html xml:lang="tr" lang="tr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ALTYAPI</title>
<meta http-equiv="content-type" contentType="text/html; charset=UTF-8">
<link rel="stylesheet" href="./static/css/reset.css" />
<script src="../static/jquery.js"></script>
<script src="../static/js/jquery-ui.js"></script>
<script src="./static/js/datetimepicker.js"></script>
<script type="text/javascript"
	src="./static/js/jquery.maskedinput.min.js"></script>
<script src="../static/js/jquery.form.min.js"></script>
<script src="../static/js/jquery.handsontable.full.js"></script>
<script src="./static/js/jquery.blockUI.js"></script>
<script src="./static/js/jquery.cookie.js"></script>
<link rel="stylesheet"
	href="./static/js/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet"
	href="./static/css/jquery.handsontable.full.css" />
<script src="{{url_for('static', filename='js/jquery.tablesorter.min.js')}}"></script>
<link rel="stylesheet"
	href="{{url_for('static', filename='css/table2.css')}}" type="text/css"
	id="" media="print, projection, screen">

<style type="text/css">
body {
	margin: 0px auto;
	padding: 0px 0px;
	font-family: calibri;
	
}
.anasablon {
	width: auto;
	height: auto;
	
}
.mheader {
	font-family: Arial, Verdana;
	text-shadow: 2px 2px 2px #ccc;
	display: block;
	float: left;
	font-weight: bold;
	padding-left: 10px;
	text-align: left;
	font-size: 15px;
	width: 1300px;
	height: 20px;
}
.formalan{
	float:left;
	width:600px;
	height:500px;
	border:#CCC solid 1px;
	background-color:#996600 ;
	margin-right: 10px;
	margin-left: 4px;
	font-family:monospace;
	font-weight: bold;
}
.raporalan{
	width:850px;
	height:500px;
	overflow: scroll;
}
.genelalan {
	float: right;
	width: 899px;
	height: 670;
	
}
.operbutonlar{
	width:auto; 
	margin: 5 ;
	font-family:monospace;
	font-weight: bold;
}
.element{
	width:360px; 
	margin: 10 ;
	float:center;
	font-family:monospace;
	font-weight: bold;
}
p{ 
	margin:5px 0; 
}
hr {
	top:5px; 
	width: 100%;
	clear: both;
	margin: auto;
}

.mheader,.formalan,.raporalan{
	margin: 3px;
	padding: 15px;
	background:#669999;
	border: 1px solid #cccccc;
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	border-radius: 6px;
	-moz-box-shadow: 2px 2px 2px #cccccc;
	-webkit-box-shadow: 2px 2px 2px #cccccc;
	box-shadow: 2px 2px 2px #cccccc;
}
</style>
<script>
	$(document).ready(function() {
		$('#calistir').on('click', function(event){
			event.preventDefault();
			var formOption = {
				url				: "/sqlCalistir",
				type			: "POST",
				target	:"#raporalan",
				success			: raporGetir
				//beforeSubmit 	: kontrolStkHarListSil
			};
			$('#raporForm').ajaxSubmit(formOption);
		});
		
		$('#sqllist').change(function(){
			$.ajax({
				url : "/sqlAl?mod="+$('#mod').val() +"&dosya="+$('#sqllist').val(),
			}).done(function(data) {
				$("#sqlkod").val(data);
			});
			
		});
		
		$('#yeniKaydet').on('click', function(event){
			event.preventDefault();
			$('#kayitmodu').val('w');
			var formOption = {
				url				: "/sqlKaydet",
				type			: "POST",
				success: function (data) {
						if(data=='tamam'){
							islemTamam("Yeni Sql Kaydı Yapıldı.");
						}else{
							hataGoster(data);
						}
					}
			};
			$('#raporForm').ajaxSubmit(formOption);
		});
		
		$('#guncelle').on('click', function(event){
			event.preventDefault();
			$('#kayitmodu').val('a');
			var formOption = {
				url				: "/sqlKaydet",
				type			: "POST",
				success: function (data) {
						if(data=='tamam'){
							islemTamam("Sql Kaydı Güncellendi.");
						}else{
							hataGoster(data);
						}
					}
			};
			$('#raporForm').ajaxSubmit(formOption);
		});
		
	});
	
	function raporGetir(res, statusText, xhr, $form) {
		//console.log(res);
		if(res!='None'){
			$("#raporalan").html(res);
			$("#hareketrapor").tablesorter();
		}
	}
	
	function islemTamam(message) {
		// TODO: hata mesajı dön
		$.blockUI({ 
            message: message, 
            fadeIn: 500, 
            fadeOut: 500, 
            timeout: 2000, 
            showOverlay: false, 
            centerY: false, 
            css: { 
                width: '550px',
                top: '6px', 
                left: '', 
                right: '100px', 
                border: 'none', 
                padding: '10px', 
                backgroundColor: '#080', 
                '-webkit-border-radius': '6px', 
                '-moz-border-radius': '6px', 
                'border-radius': '6px',
                opacity: .6, 
            	'font-style': 'italic',
	        	'font-weight': 'normal',
	        	'font-family': 'Georgia, "Times New Roman", Times, serif',
	        	'font-size': '16px',
	        	color: '#fff'
            }
        });
	}
	
	function hataGoster(message) {
		
		console.log("HATA:" + message);
		$.blockUI({ 
            message: message, 
            fadeIn: 500, 
            fadeOut: 500, 
            timeout: 2000, 
            showOverlay: false, 
            centerY: false, 
            css: { 
                width: '550px',
                top: '6px', 
                left: '', 
                right: '100px', 
                border: 'none', 
                padding: '10px', 
                backgroundColor: '#900', 
                '-webkit-border-radius': '6px', 
                '-moz-border-radius': '6px', 
                'border-radius': '6px',
                opacity: .6, 
            	'font-style': 'italic',
	        	'font-weight': 'normal',
	        	'font-family': 'Georgia, "Times New Roman", Times, serif',
	        	'font-size': '16px',
	        	color: '#fff',
                
            }
        });
	}
	
</script>
</head>

<body bgcolor='silver' > 
<div class=anasablon>
	<div class="mheader" tabindex="-1">
		<a href="/altyapiModul"><img src="altyapi.png" class="hover" hinttext="Altyapı" style="margin-right:120px;"></a> 
		<a href="/raporModul"><img src="rapor.png" class="hover" hinttext="Rapor" style="margin-right:20px;"></a> 
		<a href="/stokModul"><img src="stok.png" class="hover" hinttext="Stok" style="margin-right:20px;"></a> 
		<a href="/faturaModul"><img src="fatura.png" class="hover" hinttext="Fatura" style="margin-right:20px;"></a> 
		<a href="/cariModul"><img src="cari.png" class="hover" hinttext="Cari" style="margin-right:20px;"></a> 
		<a href="/siparisModul"><img src="spr.png" class="hover" hinttext="Sipariş" style="margin-right:20px;"></a> 
		<a href="/sayimModul"><img src="pencil.png" class="hover" hinttext="Sayım" style="margin-right:20px;"></a> 
		<a href="/veriModul"><img src="veri.png" class="hover" hinttext="Veri" style="margin-right:20px;"></a> 
		<a href="/yetkiliModul"><img src="config.png" class="hover" hinttext="Yetkili" style="margin-right:20px;"></a> 
		<a href="/logModul"><img src="log.png" class="hover" hinttext="Log" style="margin-right:20px;"></a> 
		<a href="/exit"><img src="cikis.png" class="hover" hinttext="ÇIKIŞ" style="margin-left:40px;"></a> 
		<div class="kulblok">{{kullanici}}</div>
	</div><br>
	<div class=formalan>
		
		<form id=raporForm name=raporForm action="{{ url_for('altyapiModul') }}" method=post>
		<div class=element>
		<textarea id=sqlkod name=sqlkod value="" ondblclick=this.value='' style="font-size: 18px;;margin-top: 3px;width:500px;height: 200px;"></textarea>
		</div>
		<div class=element>
		<input type="submit" name="calistir" id="calistir" value="Çalıştır" tabindex="-1"/>
		</div>
		<div class=element>
			<select name="sqllist" id="sqllist" class="txt" style="width: 150px;" > 
			{% for sql in sqller %}<option>{{sql}}</option>{% endfor %}
			</select><label>SQL LİSTESİ</label>
		</div>	
		<div class=element>
			<input type=text id=yeniSql name=yeniSql  value=yeni.sql tabindex="-1" style="width: 150px;"/>
		</div>	
		<div class=element>
			<input type="submit" name="yeniKaydet" id="yeniKaydet" value="Yeni Kaydet" tabindex="-1"/>
		</div>	
		<div class=element>	
			<input type="submit" name="guncelle" id="guncelle" value="Güncelle" tabindex="-1"/>
		</div>	
		<input id="mod" name="mod"  hidden value="{{mod}}" />
		<input id="kayitmodu" name="kayitmodu"  hidden value="{{kayitmodu}}" />
		<hr noshade size=2>
		
		</form>
		
		
		
	</div>
	<div id='genelalan' class="genelalan" tabindex="-1">
		<div class=raporalan id=raporalan>
		ilgili rapor alani	
		</div>
		<hr noshade size=1>
		<div id="fsb"></div>
	</div>
</div>
</body>
</HTML>
